
//- This Source Code Form is subject to the terms of the Mozilla Public
//- License, v. 2.0. If a copy of the MPL was not distributed with this
//- file, You can obtain one at http://mozilla.org/MPL/2.0/.
//-
//- Copyright (c) 2021-present Kaleidos Ventures SL

header
    h1.title(translate="WIKI.NAVIGATION.SECTION_NAME")

ul.wiki-link-container
    li.wiki-link.fixed-link
        a.link-title(
            href=""
            tg-nav="project-wiki:project=project.slug"
            translate="WIKI.NAVIGATION.HOME"
        )

ul.sortable.wiki-link-container
    li.wiki-link.e2e-wiki-page-link(
        ng-repeat="link in wikiLinks"
        data-id!="{{ $index }}"
        tg-bind-scope
        tg-class-permission="{'is-sortable': 'add_wiki_link'}"
        ng-class="{'active': wiki.slug == link.href}"
    )
        <% if (addWikiLinkPermission) { %>
        tg-svg.dragger(svg-icon="icon-drag")
        <% } %>
        a.link-title(title!="{{ link.title }}", href!="{{ link.url }}") {{ link.title }}

        <% if (deleteWikiLinkPermission) { %>
        a.js-delete-link.remove-wiki-page(title!="{{'WIKI.DELETE_LINK_TITLE' | translate}}")
            tg-svg(svg-icon="icon-trash")
        <% } %>

        input.hidden(
            type="text"
            placeholder="{{'COMMON.FIELDS.NAME' | translate}}"
            value!="{{ link.title }}"
        )

ul.sortable.wiki-link-container
    li.new.hidden
        input(
            type="text"
            placeholder="{{'COMMON.FIELDS.NAME' | translate}}"
        )

<% if (addWikiLinkPermission) { %>
a.add-button(
    href=""
    title="{{'WIKI.NAVIGATION.ACTION_ADD_LINK' | translate}}"
)
    .button-primary.button-small
        tg-svg(svg-icon="icon-add")
    span(translate="WIKI.NAVIGATION.ACTION_ADD_LINK")
<% } %>

ul.wiki-link-container.wiki-all-links(ng-if="wikiLinks.length")
    li.wiki-link.fixed-link
        a.link-title.secondary(
            href=""
            tg-nav="project-wiki-list:project=project.slug"
            translate="WIKI.NAVIGATION.ALL_PAGES"
        )
